<?php
require_once ("db/db_connector.php");
require_once ("db/db_user.php");

// Database Access Begins ---------------------------------------- //
$con = get_db_con();
if (isset($_POST['username'])) {
	$user_list = check_user($con, $_POST);
	print_r($user_list);
	if (!$user_list) {
		header("Location: login.php");
	} else {
		session_start();
		foreach ($user_list as $user) {
			$_SESSION['user'] = $user['username'];
			$_SESSION['user_id']=$user['id'];
			$_SESSION['admin']=$user['is_admin'];
			header("Location: index.php");
		}
	}
}

close_db_con();
// Database Access Ends ------------------------------------------ //
